package com.motong.gongdan.enums;

public enum ObjectType {
    product("product", "产品"),
    workOrder("workOrder", "工单"),
    mission("mission", "任务"),
    workReport("workReport", "报工"),
    user("user", "用户"),
    stockDetail("stockMsg", "出入库明细"),
    stockMsg("stock", "出入库单"),
    processes("processes", "工序"),
    assembly("assemblyWorkOrder", "装配工单"),
    device("device", "设备");
    private String code;
    private String description;

    ObjectType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public String getCode() {
        return code;
    }

    public static String getCodeByDesc(String desc) {
        ObjectType[] ot = values();
        for (ObjectType o : ot) {
            if (o.getDescription().equals(desc)) {
                return o.getCode();
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        ObjectType[] ot = values();
        for (ObjectType o : ot) {
            if (o.getCode().equals(code)) {
                return o.getDescription();
            }
        }
        return null;
    }
}
